home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-01 | 4.7 KB | 163 lines | [TEXT/KAHL] |
- /******************************************************************************
- CNeoDialogText.c
-
- Subclass of CEditText that implements text items in dialogs.
- NeoDialogText items have a border, pass the special keys tab, enter,
- return, and escape to their supervisors, and can be validated.
-
- SUPERCLASS = CDialogText
-
- Copyright © 1991 Symantec Corporation. All rights reserved.
- Copyright © 1992 NeoLogic Systems All rights reserved.
-
-
- ******************************************************************************/
-
- #include "NeoTypes.h"
- #include <Packages.h>
- // #include <Quickdraw.h>
- #include "Commands.h"
- #include "CPaneBorder.h"
- #include "CNeoDialogText.h"
- #include "CNeoDLOGDialog.h"
- #include "CNeoDemoDoc.h"
-
- #define kBorderAmount 2 /* white space between border and text of edit field */
-
- extern CBureaucrat *gGopher; /* First in line to get commands */
-
- /******************************************************************************
- INeoDialogText
-
- Initialize a NeoDialogText object. It is initialized to not required,
- no maximum length, and not stylable. Use the SetConstraints and Specify
- methods to modify these characteristics.
-
- ******************************************************************************/
-
- void CNeoDialogText::INeoDialogText(CView *anEnclosure, CView *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing,
- short aLineWidth, Boolean aBorderVisible)
- {
- fBorderVisible = aBorderVisible;
-
- CDialogText::IDialogText(anEnclosure, aSupervisor,
- aWidth, aHeight, aHEncl, aVEncl,
- aHSizing, aVSizing, aLineWidth);
-
- } /* CNeoDialogText::INeoDialogText */
-
- /******************************************************************************
- MakeBorder
-
- Make a PaneBorder object for the NeoDialogText. Override to change
- the border appearance.
- ******************************************************************************/
-
- void CNeoDialogText::MakeBorder(void)
- {
- Rect margin;
- CPaneBorder *border;
-
- border = new(CPaneBorder);
- border->IPaneBorder(kBorderFrame);
- border->SetPattern(fBorderVisible ? &qd.black : &qd.white);
- SetRect(&margin, -kBorderAmount, -kBorderAmount, kBorderAmount, kBorderAmount);
- border->SetMargin(&margin);
- SetBorder(border);
-
- } /* CNeoDialogText::MakeBorder */
-
- void CNeoDialogText::showBorder(const Boolean aShow)
- {
- if (aShow != fBorderVisible) {
- if (aShow)
- itsBorder->SetPattern(&qd.black);
- else
- itsBorder->SetPattern(&qd.white);
- RefreshBorder();
- }
- fBorderVisible = aShow;
- }
-
- /******************************************************************************
- DoClick {OVERRIDE}
-
- Respond to a mouse click within the EditText
- ******************************************************************************/
-
- void CNeoDialogText::DoClick(
- Point hitPt, /* Mouse location in Frame coords */
- short modifierKeys, /* State of modifier keys */
- long when) /* Tick time of mouse click */
- {
- Boolean param = TRUE;
-
- inherited::DoClick(hitPt, modifierKeys, when);
-
- if (!fBorderVisible)
- BroadcastChange(NeoDialogBordersChanged, (void *)¶m);
- }
-
- /* if pasting & there is a PICT in the scrap - act as if the file picture item
- is selected. i.e., make a new image object & put the picture into it.
- */
- void CNeoDialogText::DoCommand(long theCommand)
- {
- CNeoDemoDoc * document;
-
- if(theCommand == cmdPaste) {
- document = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
- if(!document->doPaste()) /* return of zero means there was an image in the scrap */
- return;
- }
-
- inherited::DoCommand(theCommand); /* pass it on */
- }
-
- /******************************************************************************
- DoKeyDown {OVERRIDE}
-
- Handle keypresses in a DialogText object. Keys that have a special meaning
- in a dialog (tab, return, enter, and Escape) are passed to itsSupervisor,
- all other keys are passed through to the superclass.
- ******************************************************************************/
-
- void CNeoDialogText::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
- {
- CNeoDemoDoc * document;
-
- if ((theChar >= 0x08 &&
- theChar < 0x14) ||
- (theChar >= 0x20 &&
- theChar < 0xFF)) {
- document = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
- gNeoDatabase = (CNeoDatabase *)document->itsFile;
- document->setImageDirty(this, &theChar, FALSE);
- }
-
- // switch (theChar)
- // {
- // case '\t':
- // BroadcastChange(NeoDialogBordersChanged, (void *)TRUE);
- /* FALL THROUGH */
-
- // default:
- inherited::DoKeyDown(theChar, keyCode, macEvent);
- // }
-
- } /* CNeoDialogText::DoKeyDown */
-
- Boolean CNeoDialogText::BecomeGopher(Boolean fBecoming)
- {
- if (fBecoming)
- Activate();
- else
- Deactivate();
-
- return inherited::BecomeGopher(fBecoming);
- }
-
-